"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Author: William Best
" Email : xbingy@gmail.com
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
set number
filetype on 
set history=1000 
set background=dark 
syntax on 
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set showmatch
set guioptions-=T
set vb t_vb=
set ruler
set nohls
set incsearch
set cursorline
set nocp
set list listchars=tab:>-
"set mouse=a
filetype plugin on
colo evening
autocmd FileType c,cpp,pm,pl set shiftwidth=4 | set expandtab

"""""""""""""""""""""""
" python
""""""""""""""""""""""
" autocmd FileType python set omnifunc=pythoncomplete#Complete 
let OPTION_NAME = 1
let python_version_2 = 1
let g:pydiction_location = '~/.vim/complete-dict'

"""""""""""""""""""""""
" grep
"""""""""""""""""""""""
nnoremap <silent> <F3> :Bgrep<CR>

"""""""""""""""""""""""
" ctag
"""""""""""""""""""""""
map <S-c><S-c> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> 
map <S-p><S-l> :!ctags -R --perl-kinds=+pclfs --fields=+iaS --extra=+q .<CR> 
map <S-p><S-y> :!ctags -R --python-kinds=+cfmv --fields=+iaS --extra=+q .<CR> 

""""""""""""""""""""""""
" taglist
""""""""""""""""""""""""
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
"let Tlist_Auto_Open=1
let Tlist_Use_Right_Window=1
nmap <S-t> : TlistOpen<CR>

""""""""""""""""""""""""""
" cscope
""""""""""""""""""""""""""
set cscopequickfix=s-,c-,d-,i-,t-,e-

if has("cscope")  
    set csprg=/usr/bin/cscope  
    set csto=0  
    set cst  
    set csverb  
    set cspc=3  
    "add any database in current dir  
    if filereadable("cscope.out")  
    "    cs add cscope.out  
    "else search cscope.out elsewhere  
    else  
       let cscope_file=findfile("cscope.out", ".;")  
       let cscope_pre=matchstr(cscope_file, ".*/")  
       if !empty(cscope_file) && filereadable(cscope_file)  
           exe "cs add" cscope_file cscope_pre  
       endif        
     endif  
endif

""""""""""""""""""""""""
" zuptab
"""""""""""""""""""""""
let g:SuperTabDefaultCompletionType="context"

"""""""""""""""""""""""""""""
" nerdTree minibuf winmanager
"""""""""""""""""""""""""""""
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
let g:miniBufExplMoreThanOne=0

let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree"
"let g:winManagerWindowLayout="NERDTree|TagList"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap <S-w> : WMToggle<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""
" FuzzyFinder "{{{
""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:fuf_modesDisable = [ 'mrufile', 'mrucmd', ]
let g:fuf_modesDisable = []
let g:fuf_mrufile_maxItem = 400
let g:fuf_mrucmd_maxItem = 400
nnoremap <silent> zj     :FufBuffer<CR>
nnoremap <silent> zk     :FufFileWithCurrentBufferDir<CR>
nnoremap <silent> zK     :FufFileWithFullCwd<CR>
nnoremap <silent> z<C-k> :FufFile<CR>
nnoremap <silent> zl     :FufCoverageFileChange<CR>
nnoremap <silent> zL     :FufCoverageFileChange<CR>
nnoremap <silent> z<C-l> :FufCoverageFileRegister<CR>
nnoremap <silent> zd     :FufDirWithCurrentBufferDir<CR>
nnoremap <silent> zD     :FufDirWithFullCwd<CR>
nnoremap <silent> z<C-d> :FufDir<CR>
nnoremap <silent> zn     :FufMruFile<CR>
nnoremap <silent> zN     :FufMruFileInCwd<CR>
nnoremap <silent> zm     :FufMruCmd<CR>
nnoremap <silent> zu     :FufBookmarkFile<CR>
nnoremap <silent> z<C-u> :FufBookmarkFileAdd<CR>
vnoremap <silent> z<C-u> :FufBookmarkFileAddAsSelectedText<CR>
nnoremap <silent> zi     :FufBookmarkDir<CR>
nnoremap <silent> z<C-i> :FufBookmarkDirAdd<CR>
nnoremap <silent> zt     :FufTag<CR>
nnoremap <silent> zT     :FufTag!<CR>
nnoremap <silent> z<C-]> :FufTagWithCursorWord!<CR>
nnoremap <silent> z,     :FufBufferTag<CR>
nnoremap <silent> z<     :FufBufferTag!<CR>
vnoremap <silent> z,     :FufBufferTagWithSelectedText!<CR>
vnoremap <silent> z<     :FufBufferTagWithSelectedText<CR>
nnoremap <silent> z}     :FufBufferTagWithCursorWord!<CR>
nnoremap <silent> z.     :FufBufferTagAll<CR>
nnoremap <silent> z>     :FufBufferTagAll!<CR>
vnoremap <silent> z.     :FufBufferTagAllWithSelectedText!<CR>
vnoremap <silent> z>     :FufBufferTagAllWithSelectedText<CR>
nnoremap <silent> z]     :FufBufferTagAllWithCursorWord!<CR>
nnoremap <silent> zg     :FufTaggedFile<CR>
nnoremap <silent> zG     :FufTaggedFile!<CR>
nnoremap <silent> zo     :FufJumpList<CR>
nnoremap <silent> zp     :FufChangeList<CR>
nnoremap <silent> zq     :FufQuickfix<CR>
nnoremap <silent> zy     :FufLine<CR>
nnoremap <silent> zh     :FufHelp<CR>
nnoremap <silent> ze     :FufEditDataFile<CR>
nnoremap <silent> zr     :FufRenewCache<CR>
"
" F4和shift+F4调用FuzzyFinder命令行菜单""{{{
"
function! GetAllCommands()
  redir => commands
  silent command
  redir END
  return map((split(commands, "\n")[3:]),
      \      '":" . matchstr(v:val, ''^....\zs\S*'')')
endfunction

" 自定义命令行
let g:fuf_com_list=[':exe "FufBuffer                       " |" zj     ',
                   \':exe "FufFileWithCurrentBufferDir     " |" zk     ',
                   \':exe "FufFileWithFullCwd              " |" zK     ',
                   \':exe "FufFile                         " |" z<C-k> ',
                   \':exe "FufCoverageFileChange           " |" zl     ',
                   \':exe "FufCoverageFileChange           " |" zL     ',
                   \':exe "FufCoverageFileRegister         " |" z<C-l> ',
                   \':exe "FufDirWithCurrentBufferDir      " |" zd     ',
                   \':exe "FufDirWithFullCwd               " |" zD     ',
                   \':exe "FufDir                          " |" z<C-d> ',
                   \':exe "FufMruFile                      " |" zn     ',
                   \':exe "FufMruFileInCwd                 " |" zN     ',
                   \':exe "FufMruCmd                       " |" zm     ',
                   \':exe "FufBookmarkFile                 " |" zu     ',
                   \':exe "FufBookmarkFileAdd              " |" z<C-u> ',
                   \':exe "FufBookmarkFileAddAsSelectedText" |" z<C-u> ',
                   \':exe "FufBookmarkDir                  " |" zi     ',
                   \':exe "FufBookmarkDirAdd               " |" z<C-i> ',
                   \':exe "FufTag                          " |" zt     ',
                   \':exe "FufTag!                         " |" zT     ',
                   \':exe "FufTagWithCursorWord!           " |" z<C-]> ',
                   \':exe "FufBufferTag                    " |" z,     ',
                   \':exe "FufBufferTag!                   " |" z<     ',
                   \':exe "FufBufferTagWithSelectedText!   " |" z,     ',
                   \':exe "FufBufferTagWithSelectedText    " |" z<     ',
                   \':exe "FufBufferTagWithCursorWord!     " |" z}     ',
                   \':exe "FufBufferTagAll                 " |" z.     ',
                   \':exe "FufBufferTagAll!                " |" z>     ',
                   \':exe "FufBufferTagAllWithSelectedText!" |" z.     ',
                   \':exe "FufBufferTagAllWithSelectedText " |" z>     ',
                   \':exe "FufBufferTagAllWithCursorWord!  " |" z]     ',
                   \':exe "FufTaggedFile                   " |" zg     ',
                   \':exe "FufTaggedFile!                  " |" zG     ',
                   \':exe "FufJumpList                     " |" zo     ',
                   \':exe "FufChangeList                   " |" zp     ',
                   \':exe "FufQuickfix                     " |" zq     ',
                   \':exe "FufLine                         " |" zy     ',
                   \':exe "FufHelp                         " |" zh     ',
                   \':exe "FufEditDataFile                 " |" ze     ',
                   \':exe "FufRenewCache                   " |" zr     ',
                   \':exe "FufDir ~/"                        |" Change catalogue from root', 
                   \':exe "FufFile ~/"                       |" Open file from root', 
                   \]


nnoremap <silent> <S-F4> :call fuf#givencmd#launch('', 0, 'Commands >', GetAllCommands())<CR>
nnoremap <silent> <F4> :call fuf#givencmd#launch('', 0, 'Commands >', g:fuf_com_list)<CR>
"}}}

""""""""""""""""""""""""""""""""""""""
" pyflake
""""""""""""""""""""""""""""""""""""""
"let g:pyflakes_use_quickfix = 0
